From 725cb284345de61cf019b650ed1161c04c4d7a82 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Tue, 6 May 2008 15:25:16 +0000 Subject: [PATCH] Then let's keep it on image page and add it to Special:Whatlinkshere --- RELEASE-NOTES | 1 + includes/SpecialWhatlinkshere.php | 35 +++++++++++++++++++++++++++---- languages/messages/MessagesEn.php | 2 ++ maintenance/language/messages.inc | 2 ++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4a376fff95..0bba506169 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -103,6 +103,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * More relevant search snippets (turn on $wgAdvancedSearchHighlighting) * (bug 13950) Allow users to watch the user/talk pages of users they block. * (bug 13970) Allow MonoBook-based skins to specify their own print stylesheet +* Show image links on Special:Whatlinkshere === Bug fixes in 1.13 === diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index c1eb4565c4..d51e13ad82 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -51,6 +51,7 @@ class WhatLinksHerePage { $opts->add( 'hideredirs', false ); $opts->add( 'hidetrans', false ); $opts->add( 'hidelinks', false ); + $opts->add( 'hideimages', false ); $opts->fetchValuesFromRequest( $this->request ); $opts->validateIntBounds( 'limit', 0, 5000 ); @@ -94,6 +95,7 @@ class WhatLinksHerePage { $hidelinks = $this->opts->getValue( 'hidelinks' ); $hideredirs = $this->opts->getValue( 'hideredirs' ); $hidetrans = $this->opts->getValue( 'hidetrans' ); + $hideimages = $target->getNamespace() != NS_IMAGE || $this->opts->getValue( 'hideimages' ); $fetchlinks = !$hidelinks || !$hideredirs; @@ -115,6 +117,10 @@ class WhatLinksHerePage { 'tl_title' => $target->getDBkey(), ); + $ilConds = array( + 'page_id=il_from', + 'il_to' => $target->getDBkey(), + ); $namespace = $this->opts->getValue( 'namespace' ); if ( is_int($namespace) ){ @@ -149,13 +155,19 @@ class WhatLinksHerePage { $tlConds, __METHOD__, $options ); } - if( ( !$fetchlinks || !$dbr->numRows( $plRes ) ) && ( $hidetrans || !$dbr->numRows( $tlRes ) ) ) { + if( !$hideimages ) { + $options['ORDER BY'] = 'il_from'; + $ilRes = $dbr->select( array( 'imagelinks', 'page' ), $fields, + $ilConds, __METHOD__, $options ); + } + + if( ( !$fetchlinks || !$dbr->numRows( $plRes ) ) && ( $hidetrans || !$dbr->numRows( $tlRes ) ) && ( $hideimages || !$dbr->numRows( $ilRes ) ) ) { if ( 0 == $level ) { $wgOut->addHTML( $this->whatlinkshereForm() ); $errMsg = is_int($namespace) ? 'nolinkshere-ns' : 'nolinkshere'; $wgOut->addWikiMsg( $errMsg, $this->target->getPrefixedText() ); // Show filters only if there are links - if( $hidelinks || $hidetrans || $hideredirs ) + if( $hidelinks || $hidetrans || $hideredirs || $hideimages ) $wgOut->addHTML( $this->getFilterPanel() ); } return; @@ -167,6 +179,7 @@ class WhatLinksHerePage { if( $fetchlinks ) { while ( $row = $dbr->fetchObject( $plRes ) ) { $row->is_template = 0; + $row->is_image = 0; $rows[$row->page_id] = $row; } $dbr->freeResult( $plRes ); @@ -175,10 +188,19 @@ class WhatLinksHerePage { if( !$hidetrans ) { while ( $row = $dbr->fetchObject( $tlRes ) ) { $row->is_template = 1; + $row->is_image = 0; $rows[$row->page_id] = $row; } $dbr->freeResult( $tlRes ); } + if( !$hideimages ) { + while ( $row = $dbr->fetchObject( $ilRes ) ) { + $row->is_template = 0; + $row->is_image = 1; + $rows[$row->page_id] = $row; + } + $dbr->freeResult( $ilRes ); + } // Sort by key and then change the keys to 0-based indices ksort( $rows ); @@ -237,7 +259,7 @@ class WhatLinksHerePage { static $msgcache = null; if ( $msgcache === null ) { static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator', - 'whatlinkshere-links' ); + 'whatlinkshere-links', 'isimage' ); $msgcache = array(); foreach ( $msgs as $msg ) { $msgcache[$msg] = wfMsgHtml( $msg ); @@ -254,6 +276,8 @@ class WhatLinksHerePage { $props[] = $msgcache['isredirect']; if ( $row->is_template ) $props[] = $msgcache['istemplate']; + if( $row->is_image ) + $props[] = $msgcache['isimage']; if ( count( $props ) ) { $propsText = '(' . implode( $msgcache['semicolon-separator'], $props ) . ')'; @@ -366,7 +390,10 @@ class WhatLinksHerePage { unset($changed['target']); // Already in the request title $links = array(); - foreach( array( 'hidetrans', 'hidelinks', 'hideredirs' ) as $type ) { + $types = array( 'hidetrans', 'hidelinks', 'hideredirs' ); + if( $this->target->getNamespace() == NS_IMAGE ) + $types[] = 'hideimages'; + foreach( $types as $type ) { $chosen = $this->opts->getValue( $type ); $msg = wfMsgHtml( "whatlinkshere-{$type}", $chosen ? $show : $hide ); $overrides = array( $type => !$chosen ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 23ab312b4f..851acce91d 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2247,12 +2247,14 @@ $1', 'nolinkshere-ns' => "No pages link to '''[[:$1]]''' in the chosen namespace.", 'isredirect' => 'redirect page', 'istemplate' => 'inclusion', +'isimage' => 'image link', 'whatlinkshere-prev' => '{{PLURAL:$1|previous|previous $1}}', 'whatlinkshere-next' => '{{PLURAL:$1|next|next $1}}', 'whatlinkshere-links' => '← links', 'whatlinkshere-hideredirs' => '$1 redirects', 'whatlinkshere-hidetrans' => '$1 transclusions', 'whatlinkshere-hidelinks' => '$1 links', +'whatlinkshere-hideimages' => '$1 image links', 'whatlinkshere-filters' => 'Filters', # Block/unblock diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index f8e521edcd..08baa51260 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1518,9 +1518,11 @@ $wgMessageStructure = array( 'nolinkshere-ns', 'isredirect', 'istemplate', + 'isimage', 'whatlinkshere-prev', 'whatlinkshere-next', 'whatlinkshere-links', + 'whatlinkshere-hideimages', 'whatlinkshere-hideredirs', 'whatlinkshere-hidetrans', 'whatlinkshere-hidelinks', -- 2.20.1